<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { ElScrollbar } from 'element-plus'

const max = ref(0)
const value = ref(0)
const innerRef = ref<HTMLDivElement>()
const scrollbarRef = ref<InstanceType<typeof ElScrollbar>>()

const scroll = ({ scrollLeft, scrollTop }) => {
    console.log('scrollTop:', scrollTop)
}

onMounted(()=>{
    
    scrollbarRef.value!.setScrollTop()
})
</script>
<template>
    <el-scrollbar ref="scrollbarRef" height="400px" @scroll="scroll">
        <div ref="innerRef">
            <p v-for="item in 20" :key="item" class="scrollbar-demo-item">{{ item }}</p>
        </div>
    </el-scrollbar>
</template>

<style scoped>
.scrollbar-demo-item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    margin: 10px;
    text-align: center;
    border-radius: 4px;
    background: var(--el-color-primary-light-9);
    color: var(--el-color-primary);
}
</style>